﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PJB.FacetedNavigation;

namespace PJBWebsite
{
    public partial class Detail : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            using (var factory = RepositoryConnection.GetFactory())
            {
                var service = factory.CreateChannel();
                var query = new ListingQuery(this.Request.Url.PathAndQuery);
                query.FieldFilters.Add(new FieldFilterJobID() { Comparer = Celeriq.Common.ComparisonConstants.Equals, JobID = Convert.ToInt32(this.Request["id"]) });
                var results = RepositoryConnection.QueryData(query, service);
                var item = results.RecordList.FirstOrDefault();
                if (item == null)
                {
                    this.Response.Redirect("/results.aspx");
                    return;
                }

                lblHeader.Text = item.Position_type + " " + item.Specialty + " Job in " + item.State;
                lblDescription.Text = item.Description;
                lblJobType.Text = item.Job_type;
                lblPositionType.Text = item.Position_type;
                lblPostDate.Text = item.PostDate.Value.ToString("MMMM dd, yyyy");
                lblSpecialty.Text = item.Specialty;
                lblState.Text = item.State;
            }

        }
    }
}